#if 1
// server test
#include "TcpServer.h"
#include <string.h>
#include <unistd.h>
#include <iostream>

int main() {
    int ret = 0;
    TcpServer tcpServer("127.0.0.1", 8080, 5, ret);
    if(0 != ret) {
        return -1;
    }
    // while(1) {}
    tcpServer.wait_tcp_link();
    char buf[1024] = {0,};
    tcpServer.s_read(buf, 1024);
    char* buf1 = "Hello from Server";
    tcpServer.s_write(buf1, strlen(buf1));
    sleep(5);
    return 0;
}

#else
// client test
#include "TcpClient.h"
#include <string.h>
#include <unistd.h>
#include <iostream>

int main() {
    TcpClient tcpClient("127.0.0.1", 8080);
    char* buf1 = "Hello from Client";
    tcpClient.net_write(buf1, strlen(buf1));
    char buf[1024] = {0,};
    tcpClient.net_read(buf, 1024);
    std::cout << "Client read: " << buf << std::endl;
    sleep(5);
    return 0;
}

#endif